//
//  CFChooseDateVC.m
//  CFfuturestalent
//
//  Created by 子yu 刘 on 2018/5/1.
//  Copyright © 2018年 子yu 刘. All rights reserved.
//

#import "CFChooseDateVC.h"
#import "DatePickerView.h"

@interface CFChooseDateVC ()

@end

@implementation CFChooseDateVC{
    NSDate * _startDate;
    NSDate * _endDate;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem barBtnItemWithTitle:@"完成" target:self action:@selector(complete)];
}

- (void)complete{
    if (_dateBlock) {
        self.dateBlock(_startDate,_endDate);
    }
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    MJWeakSelf;
    if (indexPath.row == 0) {
//        if (_endDate) {
//            [DatePickerView sharedInstance].maxDate = _endDate;
//        }
        [DatePickerView showToView:self.view selectedData:^(NSDate *date) {
            weakSelf.lbStartDate.text = [DateUtil stringFromDate:date Format:DateStyleDefault_YMD];
            self->_startDate = date;
        }];
        
    }else if (indexPath.row == 1){
//        if (_startDate) {
//            [DatePickerView sharedInstance].minDate = _startDate;
//        }
        [DatePickerView showToView:self.view selectedData:^(NSDate *date) {
            self.lbEndDate.text = [DateUtil stringFromDate:date Format:DateStyleDefault_YMD];
            self->_endDate = date;
        }];
    }
}
-(void)clickBtn:(NSInteger)index dateTime:(NSString *)str{
    
}
@end
